//
//  roverKonstants.m
//  CommandCenter08
//
//  Created by Matt Roman on 7/30/08.
//  Copyright 2008 University of Oklahoma. All rights reserved.
//

#import "roverKonstants.h"


@implementation roverKonstants

- (void)setClientConnection:(NetClient*)cc
{
	clientConnection = cc;
	if(clientConnection) [sendButton setEnabled:YES];
}
- (IBAction)sendKonstants:(id)sender
{
	[self setKPanel];
	if(clientConnection){
		[clientConnection sendString:@"UpdateKonstants" encoding:NSASCIIStringEncoding];
		[clientConnection sendData:[NSData dataWithBytes:&rk length:sizeof(konstants)]];
		[self close];
	}
	else {
		NSBeep();
		[sendButton setEnabled:NO];
	}
}

- (void)getKPanel
{
	[MagDeclination setFloatValue:rk.DECLINATION];
	[WheelDiam setFloatValue:rk.WHEELDIAM];
	[LeftTicksPerRev setIntValue:rk.LTICSPERREV];
	[RightTicksPerRev setIntValue:rk.RTICSPERREV];
	[RoverWidth setFloatValue:rk.ROVERWIDTH];
	[RoverWidthInt setIntValue:rk.ROVERWIDTHINT];
	[TeleportDist setFloatValue:rk.TELEPORTDISTANCE];
	[CloseEnough setFloatValue:rk.CLOSEENOUGH];
	[NoProgressTime setIntValue:rk.NOPROGRESSTIME];
	[StallPercentage setFloatValue:rk.STALLPERCENTAGE];
	[TurnDiff setFloatValue:rk.TURNDIFF];
	[PointTurnAngle setFloatValue:rk.POINTTURNANGLE];
	[PointturnSpeed setFloatValue:rk.POINTTURNSPEED];
	[PointTurnStallTime setIntValue:rk.PTSTALLTIME];
	[TurnMultiplier setFloatValue:rk.TURNMULT];
	[TurnCorrection setFloatValue:rk.NEEDTURNCORRECTION];
	[TurnAccuracy setFloatValue:rk.TURNACCURACYLIMIT];
	[RoverCruiseSpeed setIntValue:rk.ROVERCRUISESPEED];
	[TurnIncrement setFloatValue:rk.TURNINCREMENT];
	[JoyIncrement setIntValue:rk.JOYINCREMENT];
	[SpeedLimit setIntValue:rk.SPEEDLIMIT];
	[BodyDist setIntValue:rk.BODYDIST];
	[ProfileHeight setFloatValue:rk.PROFILEHEIGHT];
	[PanelHeight setFloatValue:rk.PANELHEIGHT];
	[ProfileObstacleMax setFloatValue:rk.PROFILEOBSTACLEMAX];
	[ProfileObstacleMin setFloatValue:rk.PROFILEOBSTACLEMIN];
	[ProfileSeg setIntValue:rk.PROFILESEG];
	[PanelSeg setIntValue:rk.PANELSEGMENTS];
	[ProfileIncrement setFloatValue:rk.PROFILEINCR];
	[BodyIncrements setFloatValue:rk.BODYINCR];
	[PanelIncrements setFloatValue:rk.PANELINCR];
	[MaxPitch setFloatValue:rk.MAXPITCH];
	[MaxRoll setFloatValue:rk.MAXROLL];
	[BodyTooClose setFloatValue:rk.BODYTOOCLOSE];
	[ForeOffsetWheels setFloatValue:rk.FOROFFSETWHEELS];
	[ForeOffsetBody setFloatValue:rk.FOROFFSETBODYLASER];
	[ForeOffsetProfile setFloatValue:rk.FOROFFSETPROFILE];
	[ForeOffsetPanel setFloatValue:rk.FOROFFSETPANELLASER];
	[ForePanelGroundIntersect setFloatValue:rk.FORPANELGROUNDINTERSECT];
	[MaxDistMap setIntValue:rk.MAXDISTMAP];
	[NapTime setIntValue:rk.NAPTIME];
	[PathEfficiency setFloatValue:rk.PATHEFFICIENCY];
	[TurnFactor setFloatValue:rk.TURNFACTOR];
	[GoPastDist setFloatValue:rk.GOPASTDIST];
	[PanelObstacles setIntValue:rk.PANELOBSTACLES];
	[BodyObstacles setIntValue:rk.BODYOBSTACLES];
	[ProfileObstacles setIntValue:rk.PROFILEOBSTACLES];
	[SlopeObstacles setIntValue:rk.SLOPEOBSTACLES];
	[PitchDownIgnore setFloatValue:rk.PITCHDOWNIGNOREDISTOBSTACLES];
}

- (void)setKPanel
{
	rk.DECLINATION = [MagDeclination floatValue];
	rk.WHEELDIAM = [WheelDiam floatValue];
	rk.LTICSPERREV = [LeftTicksPerRev intValue];
	rk.RTICSPERREV = [RightTicksPerRev intValue];
	rk.ROVERWIDTH = [RoverWidth floatValue];
	rk.ROVERWIDTHINT = [RoverWidthInt intValue];
	rk.TELEPORTDISTANCE = [TeleportDist floatValue];
	rk.CLOSEENOUGH = [CloseEnough floatValue];
	rk.NOPROGRESSTIME = [NoProgressTime intValue];
	rk.STALLPERCENTAGE = [StallPercentage floatValue];
	rk.TURNDIFF = [TurnDiff floatValue];
	rk.POINTTURNANGLE = [PointTurnAngle floatValue];
	rk.POINTTURNSPEED = [PointturnSpeed floatValue];
	rk.PTSTALLTIME = [PointTurnStallTime intValue];
	rk.TURNMULT = [TurnMultiplier floatValue];
	rk.NEEDTURNCORRECTION = [TurnCorrection floatValue];
	rk.TURNACCURACYLIMIT = [TurnAccuracy floatValue];
	rk.ROVERCRUISESPEED = [RoverCruiseSpeed intValue];
	rk.TURNINCREMENT = [TurnIncrement floatValue];
	rk.JOYINCREMENT = [JoyIncrement intValue];
	rk.SPEEDLIMIT = [SpeedLimit intValue];
	rk.BODYDIST = [BodyDist intValue];
	rk.PROFILEHEIGHT = [ProfileHeight floatValue];
	rk.PANELHEIGHT = [PanelHeight floatValue];
	rk.PROFILEOBSTACLEMAX = [ProfileObstacleMax floatValue];
	rk.PROFILEOBSTACLEMIN = [ProfileObstacleMin floatValue];
	rk.PROFILESEG = [ProfileSeg intValue];
	rk.PANELSEGMENTS = [PanelSeg intValue];
	rk.PROFILEINCR = [ProfileIncrement floatValue];
	rk.BODYINCR = [BodyIncrements floatValue];
	rk.PANELINCR = [PanelIncrements floatValue];
	rk.MAXPITCH = [MaxPitch floatValue];
	rk.MAXROLL = [MaxRoll floatValue];
	rk.BODYTOOCLOSE = [BodyTooClose floatValue];
	rk.FOROFFSETWHEELS = [ForeOffsetWheels floatValue];
	rk.FOROFFSETBODYLASER = [ForeOffsetBody floatValue];
	rk.FOROFFSETPROFILE = [ForeOffsetProfile floatValue];
	rk.FOROFFSETPANELLASER = [ForeOffsetPanel floatValue];
	rk.FORPANELGROUNDINTERSECT = [ForePanelGroundIntersect floatValue];
	rk.MAXDISTMAP = [MaxDistMap intValue];
	rk.NAPTIME = [NapTime intValue];
	rk.PATHEFFICIENCY = [PathEfficiency floatValue];
	rk.TURNFACTOR = [TurnFactor floatValue];
	rk.GOPASTDIST = [GoPastDist floatValue];
	rk.PANELOBSTACLES = [PanelObstacles intValue];
	rk.BODYOBSTACLES = [BodyObstacles intValue];
	rk.PROFILEOBSTACLES = [ProfileObstacles intValue];
	rk.SLOPEOBSTACLES = [SlopeObstacles intValue];
	rk.PITCHDOWNIGNOREDISTOBSTACLES = [PitchDownIgnore floatValue];
}
@end
